package com.taowan.xunbaozl.morning_speak.design_pattern.day11;

import java.util.ArrayList;
import java.util.List;

/**
 * com.taowan.xunbaozl.morning_speak.design_pattern.day11.app
 * Created by diql on 2016/3/6.
 */
public abstract class Subject {
    private List<Observer> list = new ArrayList<>();

    public void attach(Observer observer) {
        list.add(observer);
    }
    public void detach(Observer observer) {
        list.remove(observer);
    }

    public void notifyObserver() {
        for(Observer o : list) {
            o.update();
        }
    }
}
